#include <iostream>
#include <vector>
#include <ctime>
using std::cin;
using std::cout;
using std::vector;
using std::swap;
using std::distance;

void Input(vector <int> *list) {
    int count;
    cin >> count;
    list->reserve(count);
    int element;
    for (int i(0); i < count; ++i) {
        cin >> element;
        list->push_back(element);
    }
}

void Output(vector <int>::iterator iterator_begin,
    vector <int>::iterator iterator_end) {
    for (auto i = iterator_begin; i != iterator_end; ++i) {
        cout << *i << " ";
    }
}

template <typename type = int,typename iterator = vector <int>::iterator>
iterator Partition(iterator iterator_begin,
    iterator iterator_end, type pivot) {
    if (iterator_begin == iterator_end) {
        return iterator_begin;
    }
    iterator iterator_first = iterator_begin;
    iterator iterator_last = iterator_end;
    auto iterator_current = iterator_begin;
    while (iterator_current != iterator_last) {
        if (*iterator_current < pivot) {
            iter_swap(iterator_current, iterator_first);
            ++iterator_first;
            ++iterator_current;
        }
        else if (*iterator_current > pivot) {
            --iterator_last;
            iter_swap(iterator_current, iterator_last);
        }
        else {
            ++iterator_current;
        }

    }
    return iterator_first;
}

int main() {
    srand(time(NULL));
    vector <int> list;
    int average;
    Input(&list);
    cin >> average;
    auto less = distance(list.begin(), Partition(list.begin(), list.end(), average));
    cout << less << std::endl << distance(list.begin(), list.end()) - less;
}